<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<meta http-equiv="X-UA-Compatible" content="IE=edge" />

<title>AllyFolio | Privacy Settings </title>
<?php include_once("common_script_inclusions.php"); ?>
<!-- for checkbox on-off styling-->
<link rel="stylesheet" href="css/jquery.switchButton.css"/>
<style>			
    .switch-wrapper {
        display: inline-block;
        position: relative;
        top: 3px;
    }
    
    
    .slider.demo .switch-button-label {
        font-size: 20px;
    }
</style>
<!-- for checkbox on-off styling-->
</head>

<body>
<?php
require_once("includes/pagetop.php");
if(isset($_SESSION['Allyfolio_User_ID']))
{   
    if($_SESSION['Allyfolio_User_ID']<0){
        redirect("accountblocked.php");    
    }
}
else{
    redirect("index.php");
}
//echo $_SESSION['Allyfolio_User_ID'];
include_once("updates/CommonFeatures.php");

$loggedUserObj=new UserDetails();
if (!isset($_SESSION["User_details"])){
    $_SESSION["Privacy_Settings"]=$loggedUserObj->getUserPrivacyDetails($_SESSION["Allyfolio_User_ID"]);
}
//echo "<pre>";
//print_r($_SESSION["Privacy_Settings"]);

?>
	<div id="main_wrapper">
    <!--=================Header Start=======================-->
	<div class="wrapper row1">
	<div class="header">
    	<div class="log_button">
		<table width="744" border="0" style="margin-top:5px;">
			<tr>
				<td width="24">
					<a href="#"><img src="images/navico_1.png" /></a>				</td>
				<td width="36">
					<a href="#"><img src="images/navico_2.png" /></a>				</td>
				<td width="26">
					<a href="#"><img src="images/navico_3.png" /></a>				</td>
				<td width="30">
					<a href="#"><img src="images/navico_4.png" /></a>				</td>
					<td width="594">
					<!--<ul class="dn_txt3">
						<li><img src="images/dna_txt_right.png" /></li>
						<li><input type="text" class="dna_txt2" /></li>
						<li><img src="images/dna_txt_left.png" /></li>
					</ul>-->
					
					</td>
			</tr>
		  </table>
		</div>
		
       
    	
        <a href="index.html" class="logo"></a>
    </div>
    <div class="clearfix"></div>  
    
    
    </div>
    <div class="clearfix"></div>
    <!--=================Header end=======================-->
    
    
    
    <!--=================Body Contain Start=======================-->
    <div class="wrapper">
      <div class="header acSetting">
          <h1>Settings</h1>     
             <table cellpadding="0" cellspacing="0" width="100%">
                <tr>
                    <td style="vertical-align: top;">
                          <div >
                          <?php  
                          include_once("settings_menu.php");
                          include_once("includes/common_snippets.php");
                          ?>
                          </div>
                    </td>
                    <td style="vertical-align: top;">    
                        <form name="frmprivacysettings" id="frmprivacysettings" action="ajax/generic_crudoperations.php">
                          <div class="acSettingSecR" style="float: right;border:1px #999 ">
                             <div class="fieldSec"><label class="w245">Contact me for friendship</label> 
                             <?php
                            $oDropfilters= new CGetFilters();
                            $privacyTypes=$oDropfilters->getFilters("privacy_types",1,true);
                            ?>  
                            <select id="contact_for_friendship" id="contact_for_friendship">
                                <?php
                                $myprivacysetting=0;
                                if (!empty($_SESSION["Privacy_Settings"])) {
                                    $myprivacysetting = trim($_SESSION["Privacy_Settings"]["contact_me_for_friendship"]);
                                }
                                if(is_numeric($myprivacysetting) && $myprivacysetting>0){
                                    $defaultSelected=$myprivacysetting;
                                }
                                else{
                                    $defaultSelected=1; //privacy type assigned    
                                }
                                foreach($privacyTypes as $privacyType){
                                    if($privacyType["ID"]==$defaultSelected){
                                        $selected=true;
                                    }
                                    else if($privacyType["keyword"]=="public"){
                                        $selected=true;
                                    }
                                    else{
                                        $selected=false;
                                    }
                                    
                                    switch($privacyType["keyword"]){
                                        case "friends":
                                        case "choose_cluster":
                                        case "specific_friend":
                                        case "only_me":
                                            continue;
                                            break;
                                        default:
                                        
                                    ?>
                                    <option value="<?php echo $privacyType["ID"] ?>" <?php if($selected){  ?>selected="true" <?php } ?> >
                                        <?php echo $privacyType["Privacy_Type_Title"]; ?> 
                                    </option>
                                    <?php
                                    }    
                                    
                                }
                                ?>
                                </select>
                            </div>
                             <div class="fieldSec"><label class="w245">Search engine like on my DNA</label> 
                                <select id="search_on_dna"> 
                                    <?php
                                    $myprivacysetting=0;
                                    if (!empty($_SESSION["Privacy_Settings"])) {
                                        $myprivacysetting = trim($_SESSION["Privacy_Settings"]["search_on_dna"]);
                                    }
                                    ?>
                                    <option value="1" <?php echo ($myprivacysetting==1)?"selected='true'":""; ?>>Yes</option> 
                                    <option value="0" <?php echo ($myprivacysetting==0)?"selected='true'":""; ?>>No</option> 
                                </select>
                             </div>
                             <div class="fieldSec">
                                <label class="w245">E-mail address</label> 
                                <select id="email_setting" id="email_setting">
                                <?php
                                $myprivacysetting=0;
                                if (!empty($_SESSION["Privacy_Settings"])) {
                                    $myprivacysetting = trim($_SESSION["Privacy_Settings"]["email_address"]);
                                }
                                if(is_numeric($myprivacysetting) && $myprivacysetting>0){
                                    $defaultSelected=$myprivacysetting;
                                }
                                else{
                                    $defaultSelected=1; //privacy type assigned    
                                }
                                foreach($privacyTypes as $privacyType){
                                    if($privacyType["ID"]==$defaultSelected){
                                        $selected=true;
                                    }
                                    else if($privacyType["keyword"]=="public"){
                                        $selected=true;
                                    }
                                    else{
                                        $selected=false;
                                    }
                                    
                                    
                                    ?>
                                    <option value="<?php echo $privacyType["ID"] ?>" <?php if($selected){  ?>selected="true" <?php } ?> >
                                        <?php echo $privacyType["Privacy_Type_Title"]; ?> 
                                    </option>
                                    <?php
                                }
                                ?>
                               </select>
                               </div>
                             <div class="fieldSec">
                                <label class="w245">Phone No.</label> 
                                <select id="phone_no_settings" id="phone_no_settings">
                                <?php
                                $myprivacysetting=0;
                                if (!empty($_SESSION["Privacy_Settings"])) {
                                    $myprivacysetting = trim($_SESSION["Privacy_Settings"]["phone_number"]);
                                }
                                if(is_numeric($myprivacysetting) && $myprivacysetting>0){
                                    $defaultSelected=$myprivacysetting;
                                }
                                else{
                                    $defaultSelected=1; //privacy type assigned    
                                }
                                foreach($privacyTypes as $privacyType){
                                    if($privacyType["ID"]==$defaultSelected){
                                        $selected=true;
                                    }
                                    else if($privacyType["keyword"]=="public"){
                                        $selected=true;
                                    }
                                    else{
                                        $selected=false;
                                    }
                                    
                                    
                                    ?>
                                    <option value="<?php echo $privacyType["ID"] ?>" <?php if($selected){  ?>selected="true" <?php } ?> >
                                        <?php echo $privacyType["Privacy_Type_Title"]; ?> 
                                    </option>
                                    <?php
                                }
                                ?>
                               </select>
                             </div>
                             <div class="fieldSec">
                                <label class="w245">Address</label> 
                                <select id="address_settings" id="address_settings">
                                <?php
                                $myprivacysetting=0;
                                if (!empty($_SESSION["Privacy_Settings"])) {
                                    $myprivacysetting = trim($_SESSION["Privacy_Settings"]["address"]);
                                }
                                if(is_numeric($myprivacysetting) && $myprivacysetting>0){
                                    $defaultSelected=$myprivacysetting;
                                }
                                else{
                                    $defaultSelected=1; //privacy type assigned    
                                }
                                foreach($privacyTypes as $privacyType){
                                    if($privacyType["ID"]==$defaultSelected){
                                        $selected=true;
                                    }
                                    else if($privacyType["keyword"]=="public"){
                                        $selected=true;
                                    }
                                    else{
                                        $selected=false;
                                    }
                                    
                                    
                                    ?>
                                    <option value="<?php echo $privacyType["ID"] ?>" <?php if($selected){  ?>selected="true" <?php } ?> >
                                        <?php echo $privacyType["Privacy_Type_Title"]; ?> 
                                    </option>
                                    <?php
                                }
                                ?>
                               </select> 
                             </div>
                             <div class="fieldSec">
                                <label class="w245">Date Of Birth</label> 
                                <select id="dob_settings" id="dob_settings">
                                <?php
                                $myprivacysetting=0;
                                if (!empty($_SESSION["Privacy_Settings"])) {
                                    $myprivacysetting = trim($_SESSION["Privacy_Settings"]["dob"]);
                                }
                                if(is_numeric($myprivacysetting) && $myprivacysetting>0){
                                    $defaultSelected=$myprivacysetting;
                                }
                                else{
                                    $defaultSelected=1; //privacy type assigned    
                                }
                                foreach($privacyTypes as $privacyType){
                                    if($privacyType["ID"]==$defaultSelected){
                                        $selected=true;
                                    }
                                    else if($privacyType["keyword"]=="public"){
                                        $selected=true;
                                    }
                                    else{
                                        $selected=false;
                                    }
                                    
                                    
                                    ?>
                                    <option value="<?php echo $privacyType["ID"] ?>" <?php if($selected){  ?>selected="true" <?php } ?> >
                                        <?php echo $privacyType["Privacy_Type_Title"]; ?> 
                                    </option>
                                    <?php
                                }
                                ?>
                               </select> 
                               <div style="float: right;">
                               <?php
                               $mydob_date_onoff=1;
                                if (!empty($_SESSION["Privacy_Settings"])) {
                                    $mydob_date_onoff = trim($_SESSION["Privacy_Settings"]["DOB_Date_Settings"]);
                                }
                                if(is_numeric($mydob_date_onoff) && ($mydob_date_onoff==1 || $mydob_date_onoff==0)){
                                    ;   
                                }
                                else{
                                    $mydob_date_onoff=1;
                                }
                                $mydob_month_onoff=1;
                                if (!empty($_SESSION["Privacy_Settings"])) {
                                    $mydob_month_onoff = trim($_SESSION["Privacy_Settings"]["DOB_Month_Settings"]);
                                }
                                if(is_numeric($mydob_month_onoff) && ($mydob_month_onoff==1 || $mydob_month_onoff==0)){
                                    ;   
                                }
                                else{
                                    $mydob_month_onoff=1;
                                }
                                $mydob_year_onoff=1;
                                if (!empty($_SESSION["Privacy_Settings"])) {
                                    $mydob_year_onoff = trim($_SESSION["Privacy_Settings"]["DOB_Year_Settings"]);
                                }
                                if(is_numeric($mydob_year_onoff) && ($mydob_year_onoff==1 || $mydob_year_onoff==0)){
                                    ;   
                                }
                                else{
                                    $mydob_year_onoff=1;
                                }
                               ?>
                                    <div class="slider demo" id="slider-2" style="float: left;">
                                		<input type="checkbox" id="chk_showD" value="<?php echo $mydob_date_onoff;?>"/>
                                	</div>
                                    <div class="slider demo" id="slider-2" style="float: left;">
                                        <input type="checkbox" id="chk_showM" value="<?php echo $mydob_month_onoff;?>"/>
                                    </div>
                                    <div class="slider demo" id="slider-2" style="float: left;">
                                        <input type="checkbox" id="chk_showY" value="<?php echo $mydob_year_onoff;?>"/>
                                    </div>
                               </div>
                               
                             </div>
                             <div class="fieldSec">
                                <label class="w245">Fax No.</label>
                                <select id="fax_settings" id="fax_settings">
                                <?php
                                
                                
                                $myprivacysetting=0;
                                if (!empty($_SESSION["Privacy_Settings"])) {
                                    $myprivacysetting = trim($_SESSION["Privacy_Settings"]["fax_no"]);
                                }
                                if(is_numeric($myprivacysetting) && $myprivacysetting>0){
                                    $defaultSelected=$myprivacysetting;
                                }
                                else{
                                    $defaultSelected=1; //privacy type assigned    
                                }
                                foreach($privacyTypes as $privacyType){
                                    if($privacyType["ID"]==$defaultSelected){
                                        $selected=true;
                                    }
                                    else if($privacyType["keyword"]=="public"){
                                        $selected=true;
                                    }
                                    else{
                                        $selected=false;
                                    }

                                    ?>
                                    <option value="<?php echo $privacyType["ID"] ?>" <?php if($selected){  ?>selected="true" <?php } ?> >
                                        <?php echo $privacyType["Privacy_Type_Title"]; ?> 
                                    </option>
                                    <?php
                                }
                                ?>
                               </select>
                             </div>
                             
                             <div class="fieldSec">
                                <label class="w245">Family</label> 
                                <select id="family_view_settings" id="family_view_settings">
                                <?php
                                $myprivacysetting=0;
                                if (!empty($_SESSION["Privacy_Settings"])) {
                                    $myprivacysetting = trim($_SESSION["Privacy_Settings"]["family"]);
                                }
                                if(is_numeric($myprivacysetting) && $myprivacysetting>0){
                                    $defaultSelected=$myprivacysetting;
                                }
                                else{
                                    $defaultSelected=1; //privacy type assigned    
                                }
                                foreach($privacyTypes as $privacyType){
                                    if($privacyType["ID"]==$defaultSelected){
                                        $selected=true;
                                    }
                                    else if($privacyType["keyword"]=="public"){
                                        $selected=true;
                                    }
                                    else{
                                        $selected=false;
                                    }
                                    
                                    
                                    ?>
                                    <option value="<?php echo $privacyType["ID"] ?>" <?php if($selected){  ?>selected="true" <?php } ?> >
                                        <?php echo $privacyType["Privacy_Type_Title"]; ?> 
                                    </option>
                                    <?php
                                }
                                ?>
                               </select> 
                             </div>
                             <div class="fieldSec">
                                <label class="w245">Blog</label> 
                                <select id="blog_settings" id="blog_settings">
                                <?php
                                $myprivacysetting=0;
                                if (!empty($_SESSION["Privacy_Settings"])) {
                                    $myprivacysetting = trim($_SESSION["Privacy_Settings"]["Blog_Setting"]);
                                }
                                if(is_numeric($myprivacysetting) && $myprivacysetting>0){
                                    $defaultSelected=$myprivacysetting;
                                }
                                else{
                                    $defaultSelected=1; //privacy type assigned    
                                }
                                foreach($privacyTypes as $privacyType){
                                    if($privacyType["ID"]==$defaultSelected){
                                        $selected=true;
                                    }
                                    else if($privacyType["keyword"]=="public"){
                                        $selected=true;
                                    }
                                    else{
                                        $selected=false;
                                    }
                                    
                                    
                                    ?>
                                    <option value="<?php echo $privacyType["ID"] ?>" <?php if($selected){  ?>selected="true" <?php } ?> >
                                        <?php echo $privacyType["Privacy_Type_Title"]; ?> 
                                    </option>
                                    <?php
                                }
                                ?>
                               </select>
                             </div>
                             <div class="fieldSec">
                                <label class="w245">Voice Comment</label> 
                                <select id="voice_comment_settings" id="voice_comment_settings">
                                <?php
                                $myprivacysetting=0;
                                if (!empty($_SESSION["Privacy_Settings"])) {
                                    $myprivacysetting = trim($_SESSION["Privacy_Settings"]["voice_comment"]);
                                }
                                if(is_numeric($myprivacysetting) && $myprivacysetting>0){
                                    $defaultSelected=$myprivacysetting;
                                }
                                else{
                                    $defaultSelected=1; //privacy type assigned    
                                }
                                foreach($privacyTypes as $privacyType){
                                    if($privacyType["ID"]==$defaultSelected){
                                        $selected=true;
                                    }
                                    else if($privacyType["keyword"]=="public"){
                                        $selected=true;
                                    }
                                    else{
                                        $selected=false;
                                    }
                                    
                                    
                                    ?>
                                    <option value="<?php echo $privacyType["ID"] ?>" <?php if($selected){  ?>selected="true" <?php } ?> >
                                        <?php echo $privacyType["Privacy_Type_Title"]; ?> 
                                    </option>
                                    <?php
                                }
                                ?>
                               </select>
                             </div>
                             <div class="fieldSec">
                             <?php
                                $myprivacysetting=0;
                                if (!empty($_SESSION["Privacy_Settings"])) {
                                    $myprivacysetting = trim($_SESSION["Privacy_Settings"]["download_pics"]);
                                }
                                if($myprivacysetting==0){
                                    $defaultSelected=$myprivacysetting;
                                }
                                else{
                                    $defaultSelected=1; //privacy type assigned    
                                }
                                $Downloadselected=($defaultSelected==1)?true:false;
                                ?> 
                                <table>
                                    <tr>
                                        <td>
                                            <label class="w245">Download Photos</label> 
                                        
                                        </td>
                                        <td>
                                           <div class="slider demo" id="slider-download" style="float: left;">
                                         		<input type="checkbox" id="downlod_pic_setings" value="<?php echo $defaultSelected;?>"/>
                                           </div>    
                                        </td>
                                    </tr>
                                </table>
                             </div>
                             <div class="fieldSec">
                                <label class="w245">Last logged in from</label> 
                                <input type="text" placeholder="Delhi, India"  class="txtCenter" />
                             </div>
                         </div>
                       </form>
                    </td>
                </tr>
             </table>
     
     
          
     </div>
     </div>
      
    
    <div class="clearfix"></div>
    
      
    
</div>
<script type="text/javascript">
$("select").change(function(e){
    var idClicked = e.target.id;
    changePrivacySettings(idClicked,$("#"+idClicked).val());
});

function changePrivacySettings(sFor,iVal){
    var urlstr = $("#frmprivacysettings").attr( "action" );
    //alert("sfor: "+sFor+" iVal "+iVal);
    $.ajax({
	  	type: "POST",
	  	url: urlstr,
	  	cache: false,
	  	data: { 
	  	         "actiontype":"update_userprivacy_settings",   
	  	         "sFor": sFor,                                     
                 "iVal": iVal
              } 
    })
	.done(function( data ) {	
	   //alert(data);
	   var jsonParsed=$.parseJSON(data);
        console.log(jsonParsed);
        /*if(document.getElementById("errconsole")){
            document.getElementById("errconsole").innerHTML=data;
        }*/
        if(!isNaN(jsonParsed.err)){ //means have some code
            switch(parseInt(jsonParsed.err)){
                case 200:
                        //alert(jsonParsed.msg);
                        break;
                default:
                        alert(jsonParsed.msg);
                        break;
            }
        }
	})
	.fail(function(msg) { 
		console.log(msg);
//		alert("error"); 
	})
    .always(function() { 
		//alert("complete"); 
	});
}
</script>
<!-- for checkbox on-off actions-->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
    <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js"></script>
    <script src="js/jquery.switchButton.js"></script>
		<script type="text/javascript">	
			$(function() {
		        $("#slider-2.demo #chk_showD").switchButton({
		          width: 40,
		          height: 20,
		          button_width: 20,
		          labels_placement: "right",
                  on_label: "D",
                  off_label: "D",
		          checked: <?php echo ($mydob_date_onoff==1)?'true':'false'; ?>
		        });
		        $("#slider-2.demo #chk_showM").switchButton({
		          width: 40,
		          height: 20,
		          button_width: 20,
		          labels_placement: "right",
                  on_label: "M",
                  off_label: "M",
		          checked: <?php echo ($mydob_month_onoff==1)?'true':'false'; ?>
		        });
		        $("#slider-2.demo #chk_showY").switchButton({
		          width: 40,
		          height: 20,
		          button_width: 20,
		          labels_placement: "right",
                  on_label: "Y",
                  off_label: "Y",
		          checked: <?php echo ($mydob_year_onoff==1)?'true':'false'; ?>
		        });
                
                $("#slider-download.demo #downlod_pic_setings").switchButton({
		          width: 40,
		          height: 20,
		          button_width: 20,
		          labels_placement: "right",
                  on_label: "Allowed",
                  off_label: "Restricted",
		          checked: <?php echo ($Downloadselected)?'true':'false'; ?>
		        });
		    });
			$(document).ready(function(){
				$("input[type=checkbox]").change(function(e) {
					var checkboxidChanged=e.target;
				    //alert(checkboxidChanged.id);
					if($(checkboxidChanged).is(":checked")){
					   changePrivacySettings(checkboxidChanged.id,1);
						//alert(checkboxidChanged.id+ " is checked..");
					}
					else{
						//alert(checkboxidChanged.id+ " is not checked..");
                        changePrivacySettings(checkboxidChanged.id,0);
					}
				    //console(e);
				});
			});
		</script>
        
<!-- for checkbox on-off actions-->

 </body>
</html>
